import os.path

import pygame

from locals import *
import objects

class Teleport(objects.StaticObject):
	graphic = "teleport.png"
	
	def __init__(self, map, position, destination):
		super(Teleport, self).__init__(map, position)
		self.destination = destination

	def save(self, variables):
		return "%s, %s" % (super(Teleport, self).save(variables), str(self.destination))

	def stand(self, stander):
		direction = stander.direction
		print "first"
		stander.teleport(self.destination)
		
		if not stander.move(movements[direction], stander.walk_speed):
			print "second"
			stander.teleport(self.position)
			
			direction += 2
			if direction > 3:
				direction -= 4
				
			stander.move(movements[direction], stander.walk_speed)
